package com.vi.daemon;

import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.os.Process;

import com.xfhy.wallpaperdemo.DaemonLog;
import com.xfhy.wallpaperdemo.MyApplication;
import com.xfhy.wallpaperdemo.RomUtil;
import com.xfhy.wallpaperdemo.live.ViInstrumentation;
import com.xfhy.wallpaperdemo.live.nk;

public class DaemonNative {
    public static ComponentName sCN = new ComponentName(nk.getInstance().getContext(), ViInstrumentation.class);

    static {
        System.loadLibrary("vi_daemon");
    }

    public static native void forkChild(String str, String str2, String str3, String str4, String str5);

    public static native int lockFile(String str);

    public static void restartProcess() {
        DaemonLog.d("restartProcess");
        Context context = MyApplication.sContext;
        if (context != null) {
            context.startInstrumentation(sCN, (String) null, (Bundle) null);
        }
    }

    @SuppressLint({"DiscouragedPrivateApi"})
    public static void setProcessName(String str) {
        if (!RomUtil.isOppo()) {
            try {
                Process.class.getDeclaredMethod("setArgV0", new Class[]{String.class}).invoke((Object) null, new Object[]{str});
            } catch (Exception unused) {
                DaemonLog.d("setProcessName failed");
            }
        }
    }
}
